module Tech

import Indicators
const I = Indicators

function calc_atr_at_ix(buckets, focus_ix, period) :: Float64
  isempty(buckets) && return 1
  view_size = period + 1
  first_ix = focus_ix - view_size
  last_ix = focus_ix
  the_view = @view buckets[first_ix : last_ix]
  arr = map(the_view) do bucket
    [bucket.high, bucket.low, bucket.close]
  end
  arr = vcat(arr'...)
  atr = I.atr(arr, n=period)
  atr[length(atr)]
end

end
